package com.zan.spring.controller;

import com.zan.spring.service.UserService;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

/**
 * @Author Zan
 * @Create 2024/4/28 9:30
 * @Description : TODO(请用一句话描述该类的功能)
 * @ClassName: UserController
 */
public class UserController {
    public static void main(String[] args) {
        // 1.创建Spring的容器对象
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
//        BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("applicationContext.xml"));
        // 2.从容器对象中获取userService对象
        UserService userService = applicationContext.getBean("userService", UserService.class);
//        UserService userService = beanFactory.getBean("userService", UserService.class);
        // 3.调用userService方法进行业务逻辑处理
        userService.add();
    }
}
